/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#ifndef __QS_StockIndexImage_H__
#define __QS_StockIndexImage_H__



#include "Utilities.h"

namespace QSThink
{
	
	class StockMetaInfo
	{
	public:
		static const int NameMaxLen=60;//shouldn't easy change,for data in disk
		StockMetaInfo();
		StockMetaInfo(int symbol,const char* name,int nameLen);

		void set(int symbol,const char* name,int nameLen);

		int symbol;
		char name[NameMaxLen];//the name of the stock
		//total 64 bytes
	};

	//only keep stock symbol and name ,it's index(location) is a very import implicity info
	//should have two disk image file one is ShangHai
	//one is ShenZhen
	/*manipulate stock DB index file,Whole db only have one
	*/
	class StockIndexImage
	{
		static const int StockMax=1024;
		static const std::string IndexShangHai;
		static const std::string IndexShenZhen;

	public:
		StockIndexImage(ExchangeType ex);

		//Persist stock metadata and return the stock index(id) in this system
		int persist(int symbol,const char* name,int nameLen);
		// Get the stock index(id) in this system
		int getSymbolIndex( int symbol );

		std::string getStockName(int symbol);
	protected:
		ExchangeType _exchange;//exchange in shanghai or shenzhen

		int _stockCount;

		StockMetaInfo _stock[StockMax];

		std::map<int,int> _symbolMap;//easy find symbol loc(index)

	protected:
		std::string _indexFileName;
		
	};
}

#endif
